package com.itheima_test;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;
import java.util.Set;

/*
    请写一个程序判断是否有"lisi"这样的键存在，如果有就改变其实为"100"
 */
public class Test3 {
    public static void main(String[] args) throws IOException {
        //创建集合，获取文件数据
        Properties prop = new Properties();
        FileReader fr = new FileReader("myOtherStream\\score.txt");
        prop.load(fr);
        //获取集合的key，遍历集合判断是否存在lisi
        Set<String> keySet = prop.stringPropertyNames();
        for (String key : keySet) {
            if (key.equals("lisi")) {
                prop.setProperty(key, "100");
            }
            String value = prop.getProperty(key);
            System.out.println(key + "," + value);
        }

    }
}
